package com.example.factory;

/**
 * ClassName:WeaponFactory
 * Package:com.example.factory
 * Description:
 *
 * @Author:ZhangXin
 * @Create:2023/5/8-20:33
 * @Version:v1.0
 */
//工厂类角色
public class WeaponFactory {

    //静态方法,要获取什么产品和传递的参数有关
    //传 Tank 获取坦克
    //传 Dagger 获取匕首
    //传 Fighter 获取战斗机
    public static Weapon get(String weaponType){
        if ("Tank".equals(weaponType)) {
            return new Tank();
        }else if ("Fighter".equals(weaponType)){
            return new Fighter();
        }else if ("Dagger".equals(weaponType)){
            return new Dagger();
        }else {
            throw new RuntimeException("不支持该武器生产");
        }

    }
}
